package demo1;


public class LogIn {
    private String username = "admin";
    private String password = "123";

    public LogIn(String username, String passeword) {
        this.username = username;
        this.password = passeword;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public LogIn() {
    }

    public void login() throws PasswordException{
        if (!this.username.equals("admin")) {
            throw new UsernameException("用户名错误或不存在");
        }
        if (!this.password.equals("123")) {
            throw new PasswordException("密码错误");
        }
        System.out.println("登录成功！");
    }
}